package demo1;

public class LogIn {
    public String name = "baibai";
    public int age = 10;

    public void login(String name, int age) throws NameErrorException,AgeErrorException{
//        try {
            if (!this.name.equals(name)) {
                throw new NameErrorException("名字错误异常" + name);
            }
            if (this.age != age) {
                throw new AgeErrorException("年龄错误异常" + age);
            }

//            }catch (NameErrorException e){
//                System.out.println("名字错误异常...");
//                e.printStackTrace();
//            } catch (AgeErrorException e){
//                System.out.println("密码错误异常...");
//                e.printStackTrace();
//            }
            System.out.println("登陆成功");
        }
    }
